package com.team.employment.web.admin.controller.statutory;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.team.employment.common.result.Result;
import com.team.employment.model.entity.CompanyInfo;
import com.team.employment.model.entity.StatutoryInfo;
import com.team.employment.web.admin.dto.CompanyQueryDto;
import com.team.employment.web.admin.dto.StatutoryQueryDto;
import com.team.employment.web.admin.service.StatutoryInfoService;
import com.team.employment.web.admin.vo.CompanyStatutoryVo;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Tag(name = "法定人信息管理")
@RestController
@RequestMapping("/admin/statutoryInfo")
public class StatutoryInfoController {

    @Autowired
    private StatutoryInfoService statutoryInfoService;

    @Operation(summary = "分页查询所有法定人信息")
    @GetMapping("pageInfo")
    public Result<IPage<StatutoryInfo>> pageInfo(@RequestParam long current, @RequestParam long size){
        IPage<StatutoryInfo> page = new Page<>(current,size);
        IPage<StatutoryInfo> resultPage = statutoryInfoService.page(page);
        return Result.ok(resultPage);
    }

    @Operation(summary = "根据不同条件模糊分页查询法定人")
    @PostMapping("pageQueryInfo")
    public Result<IPage<StatutoryInfo>> pageQueryInfo(
            @RequestParam long current,
            @RequestParam long size,
            @RequestBody StatutoryQueryDto queryDto) {
        Page<StatutoryInfo> page = new Page<>(current, size);// 1. 构建分页参数
        IPage<StatutoryInfo> result = statutoryInfoService.queryByPage(queryDto, page);// 2. 调用Service层查询
        return Result.ok(result);// 3. 返回统一响应结构
    }

    @Operation(summary = "根据statutory_id删除法人信息")
    @DeleteMapping("removeStatutoryById/{id}")
    public Result<Void> removeStatutoryById(@PathVariable Long id){
        statutoryInfoService.removeStatutoryById(id);
        return Result.ok();
    }

}
